package cz.muni.fi.pa165.sme.web.pages.user;

import cz.muni.fi.pa165.sme.web.fo.UserFO;
import cz.muni.fi.pa165.sme.web.pages.TemplatePage;
import cz.muni.fi.pa165.sme.web.panels.user.UserForm;
import org.apache.wicket.authorization.Action;
import org.apache.wicket.authroles.authorization.strategies.role.Roles;
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeAction;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.ResourceModel;

/**
 * @author jirankova
 */
@AuthorizeAction(action = Action.RENDER, roles = {Roles.USER, Roles.ADMIN})
public class UserEditPage extends TemplatePage {
	public UserEditPage(final UserFO userFO) {
		//page title
		add(new Label("title", new ResourceModel("user.edit.title")));

		//model to update user
		final CompoundPropertyModel<UserFO> model = new CompoundPropertyModel<UserFO>(new LoadableDetachableModel<UserFO>() {
			@Override
			protected UserFO load() {
				return userFO;
			}
		});

		//form to edit user
		add(new UserForm("form", model));
	}
}
